<%@ page language="java"  pageEncoding="utf-8"%>
<%@page import="java.nio.charset.Charset"%>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<%@ page import=" java.util.Vector,com.ejoysoft.wlanyz.business.Environment,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException" %>
<%@ include file="../include/jsp/head.jsp"%>
<%
if(!globa.userSession.hasRight("20010"))
      throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
%>
<%
    //初始化
    Environment  Environment0=null;
    Environment obj=new Environment(globa);
    out.println("ssssssssssssssss");
    //查询条件
    String  strApMac=ParamUtil.getString(request,"strApMac","").trim();
    String  strStartTime = ParamUtil.getString(request,"strStartTime","");
    String  strEndTime = ParamUtil.getString(request,"strEndTime","");
	String exportContent = ParamUtil.getString(request,"exportContent","");  
	//当前页
    int intCurPage = Integer.parseInt(ParamUtil.getString(request,"strCurPage","1"));
	String tWhere=" where 1 = 1 and d.strhotspot = c.strid and d.strmac_addr = a.strapmac and a.strcommunityid = e.strcommid ";
    if(!strApMac.equals("")){
     tWhere += " and strApMac LIKE '%"+ strApMac +"%' " ;
    }
	//记录总数
	int intAllCount=obj.getCount(tWhere ,strStartTime ,strEndTime);	

	//每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","15");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
	//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;   
	//获取到当前页面的记录集
	Vector<Environment> vctObj=obj.list(tWhere,intStartNum,intPageSize,strStartTime,strEndTime);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
   
		if(exportContent.equals("allPage"))
		{
			vctObj=obj.list(tWhere,0,0,strStartTime ,strEndTime);
		}
   	   	StringBuffer sb = new StringBuffer("<html><body><table border='1'>");
   	    sb.append("<tr><td>地市</td><td>区县</td><td>一级热点</td><td>二级热点</td><td>AP名称</td><td>MAC地址</td>"
   	    +"<td>LAC</td><td>CI</td><td>操作时间</td></tr>");
	    if (vctObj.size() != 0)
	    {  
	        for (int i = 0; i < vctObj.size(); i++)
		    {   
		       sb.append("<tr><td> ");		       
		       sb.append((vctObj.get(i).getStrCity()==null?"":vctObj.get(i).getStrCity()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrTown()==null?"":vctObj.get(i).getStrTown()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrClassOneHP()==null?"":vctObj.get(i).getStrClassOneHP()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrHotPotName()==null?"":vctObj.get(i).getStrHotPotName()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getDevice_Name()==null?"":vctObj.get(i).getDevice_Name()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrApMac()==null?"":vctObj.get(i).getStrApMac()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrLac()==null?"":vctObj.get(i).getStrLac()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrCI()==null?"":vctObj.get(i).getStrCI()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getDtCreatDate()==null?"":vctObj.get(i).getDtCreatDate()));
		       sb.append("</td></tr> ");
		      
		    }
		    
	    }
   	   	sb.append("</table></body></html>");
   	   	System.out.println(sb);
	    String strFileName = "地市热点信息表.xls";//自定义xls文件的文件名
	    response.setCharacterEncoding("utf-8");
	    response.setContentType("APPLICATION/*;charset=utf-8");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1"));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    System.out.println(sb.toString().getBytes("utf-8"));
	    output.write(sb.toString().getBytes("utf-8"));
	  //out.clearBuffer(); 
	//  WarnAppear.shareMethodForExport(sb,strFileName,response,out,pageContext);
 
	
%>
<%@ include file="../include/jsp/footer.jsp"%>
